package com.hualu.serverInfo.webapp;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.hualu.serverInfo.model.ServerInfo;
import com.hualu.serverInfo.service.ServerInfoManager;

public class ServerInfoController implements Controller {

    private transient final Log log = LogFactory.getLog(ServerInfoController.class);
    private ServerInfoManager serverInfoManager;
    public static final String SERVER_LIST = "serverList";

    public void setServerInfoManager(ServerInfoManager serverInfoManager) {
        this.serverInfoManager = serverInfoManager;
    }

    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        if (log.isDebugEnabled()) {
            log.info("ServerInfo");
        }

        List<ServerInfo> list = serverInfoManager.getServerInfoList();
        return new ModelAndView("serverInfo/serverList", SERVER_LIST, list);
    }

}
